<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY imt "http://xmlns.heustics.org/schema/imt/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="http://xmlns.heustics.org/schema/myelin/0.1/" 
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:o="http://xmlns.heustics.org/schema/myelin/0.1/File#view"
  xmlns:str="http://exslt.org/strings"
  exclude-result-prefixes="xsl a l o str"
>
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;File#view')"/>
  <xsl:variable name="o:actions-l10n" select="$o:l10n/l:context[@name='actions']/*"/>
  <xsl:variable name="o:metadata-l10n" select="$o:l10n/l:context[@name='metadata']/*"/>  
     
  <xsl:template match="a:acl[@key='update-source']" mode="a:node-action">  
    <xsl:param name="key" select="string(@key)"/>
    <xsl:call-template name="a:node-action">
      <xsl:with-param name="label" select="$o:actions-l10n[@key=$key]"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="a:acl[@key='download']" mode="a:node-action">  
    <xsl:param name="key" select="string(@key)"/> 
    <xsl:call-template name="a:node-action-href-ext">
      <xsl:with-param name="label" select="$o:actions-l10n[@key=$key]"/>
      <xsl:with-param name="href-ext" select="concat('modified=',/*/a:meta/a:modified)"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="a:dict[@key='file-metadata']">
    <div class="source">
      <!--h3><xsl:value-of select="$o:l10n/l:gentext[@key='title-metadata']"/></h3-->
      <div class='metadata'>
        <xsl:apply-templates mode="a:dict">
          <xsl:with-param name="l10n" select="$o:metadata-l10n"/>
        </xsl:apply-templates>
        <div class='spacer'/>
      </div>      
    </div>
  </xsl:template>  
      
  <xsl:template match="a:entry[@key='format']" mode="a:dict"> 
    <div class='entry format'>
      <div class='key'>
        <span><xsl:value-of select="$o:metadata-l10n[@key='format']"/></span>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <xsl:variable name="mime-toks" select="str:split(.,'/')"/>
        <span><xsl:value-of select="a:get-l10n('&imt;content-type')/l:context[@name=$mime-toks[1]]/*[@key=$mime-toks[2]]"/></span>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:entry[@key='source']" mode="a:dict">
    <div class='entry'>
      <div class='key'>
        <span><xsl:value-of select="$o:metadata-l10n[@key='source']"/></span>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <a href="{concat(a:format-node-action('download'),'&amp;modified=',@modified)}">
          <xsl:value-of select="$o:actions-l10n[@key='download']"/>
        </a>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>  
  
</xsl:stylesheet>

